// mine/pages/feedbackadd/index.js
const $api = require("../../../api/mine").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    feedback_file:[],
    feedback_content:"",
    feedback_type:"",
    type:[],
    typeinfo:"",
    showtypelist:false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var t = this
    t.getFeedbackType()
  },
  getFeedbackType(){
    var t = this
    $api.getFeedbackType().then(res=>{
      t.setData({
        type:res.data,
        typeinfo:res.data[0].dict_value,
        feedback_type:res.data[0].dict_key
      })
    })
  },
  showtypelist(){
    var t= this
    t.setData({
      showtypelist:true
    })
  },
  hidetypelist(){
    var t= this
    t.setData({
      showtypelist:false
    })
  },
  onChangepicker(e){
    var t = this
    t.setData({
      typeinfo:e.detail.value.dict_value,
      feedback_type:e.detail.value.dict_key
    })
  },
  // 发布反馈
  saveFeedback() {
    var t = this,
    data = {
      feedback_file:t.data.feedback_file,
      member_id:wx.getStorageSync('memberinfo').member_id,
      feedback_content:t.data.feedback_content,
      feedback_type:t.data.feedback_type,
    }
    $api.saveFeedback(data).then(res=>{
      console.log(res)
    })
  },
  setdesc(e){
    var t = this
    t.setData({
      feedback_content:e.detail
    })
  }
})